const Router = require('koa-router')
const router = new Router({ prefix: '/addr' })
const { auth } = require('../middleware/auth.middleware')
const { addrValidator } = require('../middleware/addr.middleware')
const { create, findAll, update, remove, setDefault } = require('../controller/addr.controller')

router.post('/', auth, addrValidator({
    cosignee: 'string',
    phone: 'string',
    address: 'string'
}), create)
router.get('/', auth, findAll)
router.put('/:id', auth, addrValidator({
    cosignee: 'string',
    phone: 'string',
    address: 'string'
}), update)
router.delete('/:id', auth, remove)
router.patch('/:id', auth, setDefault)

module.exports = router